﻿namespace Attacher
{
    using System;

    using Hardcodet.Wpf.TaskbarNotification;

    internal class ExceptionReportingService : IExceptionReportingService
    {
        #region Attributes

        private readonly TaskbarIcon taskbarIcon;

        #endregion

        #region Constants

        private const string ErrorMessage = "Unexpected Exception Received" + "\n" + "The application will finish: False" + "\n" + "Message: {0}"; 

        #endregion

        #region Public Methods

        public ExceptionReportingService(TaskbarIcon taskbarIcon)
        {
            ParameterChecker.IsNotNull(taskbarIcon, "taskbarIcon");

            this.taskbarIcon = taskbarIcon;
        }

        public void ReportException(Exception exception)
        {
            this.NotifyException(exception);
        }

        #endregion

        #region Private Methods

        private void NotifyException(Exception ex)
        {
            this.taskbarIcon.ShowBalloonTip("Exception Detected", string.Format(ErrorMessage, ex.Message), BalloonIcon.Error);
        }

        #endregion
    }
}
